<?php

class jssdk
{
    public function index()
    {
        //时间戳
        $timestamp = time();

        //票据
        $jsapi_ticket = Wechat::getJsapiTicket();

        //随机字符串
        $nonceStr = substr(md5(rand(1111, 9999)), 0, 20);

        $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];

        //签名字符串
        $string = "jsapi_ticket={$jsapi_ticket}&noncestr={$nonceStr}&timestamp={$timestamp}&url={$url}";
        //签名计算
        $signature = sha1($string);
        $configArr = [
            'appId' => 'wxb56bc1c1ee0e0770', // 必填，公众号的唯一标识
            'timestamp' => $timestamp, // 必填，生成签名的时间戳
            'nonceStr' => $nonceStr, // 必填，生成签名的随机串
            'signature' => $signature,// 必填，签名
        ];
        include("./view/jssdk/index.php");
    }
}